<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/WEB-INF/view/system/common/head.jsp"%>

<style>
 .labelTd{
    width:100px;
    text-align:right;
 }
</style>

<body>
	<form id="parameterAddForm" name="parameterAddForm" method="post">
		<div id="p" class="easyui-panel" title="添加参数" style="padding: 10px; background: #fafafa;text-align:center;">
			<fieldset>
				<legend style="color: blue;font-size:1.5" > 参数信息 </legend>
				<input type="hidden" name="level" value="1" />
				<table class="infoTable">
					<tr>
						<td class="labelTd" >参数类型：</td>
						<td class="redText"><!-- <s:select
								onchange="parameterTypeChanged()" id="newParameter_type"
								name="newParameter.type" list="#request.parameterTypeList"
								listKey="value" listValue="name" style="width:150px" /> -->
						<select id="newParameter_type" name="type"  style="width: 100px; border-radius: 5px;height: 24px;"
						onchange="parameterTypeChanged()" >
						
						   <c:forEach items="${parameterTypeList}" var="parameterTypeItem" >
						     <option value="${parameterTypeItem.value }">${parameterTypeItem.name }</option>
						  </c:forEach>
						 </select>
						 	
								
						</td>
					</tr>
					<tr>
						<td class="labelTd" >名称<span class="colrRed"> * </span>：
						</td>
						<td ><input type="text" id="newParameter_name"
							name="name" maxlength="30"
							class="easyui-validatebox myinput"  required="true" 
							missingMessage="请输入名称"  placeholder="请输入名称"/></td>
						<td class="labelTd" >编码<span class="colrRed"> * </span>： </td>
						<td ><input type="text" id="newParameter_code"
							name="code" class="easyui-validatebox myinput"
							 maxlength="15" 
							required="true"
							missingMessage="请输入编码"  placeholder="请输入编码" /></td>
					</tr>
					
					<tr id="singerParameterTR">
						<td class="labelTd">参数值：</td>
						<td ><input type="text" id="newParameter_value"
							name="value" maxlength="30"
							class="easyui-validatebox myinput" 
							  placeholder="请输入参数值"/></td>
						<td class="labelTd" >更改后生效时间：</td>
						<td ><!-- s:select id="newParameter_effectType"
								name="newParameter.effectType"
								list="#request.parameterEffectTypeList" listKey="value"
								listValue="name" style="width:150px" /> -->
						<select id="newParameter_effectType" name="effectType"  class="easyui-combobox"
 style="width: 100px; border-radius: 5px;height: 24px;">
						
						   <c:forEach items="${parameterEffectTypeList}" var="parameterEffectTypeItem" >
						     <option value="${parameterEffectTypeItem.value }">${parameterEffectTypeItem.name }</option>
						  </c:forEach>
						 </select>
						 		
						</td>
					</tr>
				</table>
			</fieldset>
			<div style="text-align:center;">
				<br /> <a class="easyui-linkbutton myLink" iconCls="icon-ok"
					onclick="submitForm()">新增 </a>
				&nbsp;&nbsp;&nbsp; <a  class="easyui-linkbutton myLink"
					iconCls="icon-undo" onclick="resetFrom()">重置
				</a>
			</div>
		</div>
	</form>
</body>

<script>
	//重置
	function resetFrom() {
		$("#parameterAddForm").form("reset");
	}

	//页面提交
	function submitForm() {
		//判断参数是否为空
		var valid = $('#parameterAddForm').form('validate');
		if (valid) {
			//获取页面上所有的参数
			//var param = getFormElementsForUrl();
			//提交后台处理  
		//	$.post("doParameterAdd.action" + param, callbackAdd);
			var param = $("#parameterAddForm").serializeJson(true);
			$.axs("parameter/doParameterAdd.action", param,
		            function(data){
				if(data.status == 1){
					$.messager.alert("提示信息",data.msg, 'info', function() {
						parent.$("#parameterDataGrid").datagrid('reload');
						resetFrom();
					});
				}else{
					$.messager.alert("提示信息", data.msg, 'error');
				}
			});	

		}
	}


	function parameterTypeChanged() {
		var parameterType = $('#newParameter_type').val();
		if (parameterType == 1) {
			//单参数，显示
			$('#singerParameterTR').show();
		} else if (parameterType == 2) {
			//多参数
			$('#singerParameterTR').hide();
		}
	}
</script>
</html>